<!DOCTYPE html>
{% extends "base.html" %}
{% block title %} Babay {% endblock %}

{% block user %} {{ current_user.username }} {% endblock %}

<!-- Replace the `body` of template base.html -->
{% block body %}
	<!-- the data object form view function: `home()` -->
	<div class="row">
		<div class="col-lg-9">
			<!-- Get Pagination object -->
			{% for post in posts.items %}
				<div class="row">
					<div class="col-lg-12">
						<h1>{{ post.title }}</h1>
					</div>
				</div>
				<div class="row">
					<div class="col-lg-12">
						{{ post.text | truncate(255) | safe }}
						<!-- Set the link for read more -->
						<a href="{{ url_for('blog.post', post_id=post.id) }}">
							READ MORE
						</a>
					</div>
				</div>
			{% endfor %}
		</div>
		
		<div class="col-lg">
			<div class="row-">
				<h5>Recent Posts</h5>
				<ul>
					{% for post in recent %}
						<!-- Set the link for recent posts -->
						<li>
							<a href="{{ url_for('blog.post', post_id=post.id) }}">
								{{ post.title }}
							</a>
						</li>
					{% endfor %}
				</ul>
			</div>
			<div class="row-">
				<h5>Popular Tags</h5>
				<ul>
					{% for tag in top_tags %}
					<li>
						<a href="{{ url_for('blog.tag', tag_name=tag[0].name) }}">
							{{ tag[0].name }}
						</a>
					</li>
					{% endfor %}
				</ul>
			</div>
		</div>
		<div class="col">
		<!-- Call the Macro `render_pagination` from `base.html` -->
		{{ render_pagination(posts, 'blog.home') }}
		</div>
	</div>
{% endblock %}